<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css"/>
    <style>
    	html,body{
    		height: 98%;
			background: transparent;
			-webkit-touch-callout: none;
			font-family: Tahoma, Geneva, sans-serif;
			font-style: normal;
		}
		#dialog{
			padding:5px 10px 10px 10px;
			background-color: #e7e7e7; border-radius: 6px;
			position: absolute; margin: auto;
			left: 0; right: 0; top: 0; bottom: 0;
			width: 250px; height: 290px;
			-webkit-transition: all .1s;
			transition:all .1s;
			-webkit-transform: scale(0);
			transform:scale(0);
			opacity: 0;
		}
		#dialog.in{
			-webkit-transform: scale(1);
			transform:scale(1);
			opacity: 1;
		}
		img{
			padding:15px;
		}
    </style>
</head>
<body>
	
	<div id="dialog" >
		<span style="width:100%;text-align: center;font-size:18px;margin-bottom:10px;"><b>我的推广二维码</b> <a href="javascript:void(0)" onclick="fxqr()">保存图片</a></span>
		<!-- <img id="erweima" src="../image/myerweima.png" tapmode onclick="api.closeFrame()"/> -->
	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script src="../resource/jquery-1.js"></script>
<script src="../resource/qrcode.js"></script>
<script src="../resource/jquery-barcode.js"></script>
<script type="text/javascript">
	$('#dialog').addClass('in');
	var phone = $api.getStorage("dl_phone");
	apiready = function(){		
		var qrcode = new QRCode("dialog", {
    							    text : "http://wechat.scjinsui.com/weixin/wx/tglogin.jsp?phone=" + phone,
    							    width: 250,
    							    height: 250,
    							    colorDark : "#000000",
    							    colorLight : "#ffffff",
    							    correctLevel : QRCode.CorrectLevel.H
    							});
	
		$(document.body).on('touchend',function(e){
			var dialog = $("#dialog")[0];
			if(!$.contains(dialog, e.target)){
				$('#dialog').removeClass('in');
				setTimeout(function(){
					api.closeFrame();
				},200);
			}
		});
	};
	
	
	function fxqr(){
		var FNScanner = api.require('FNScanner');
		FNScanner.encodeImg({
		    content: "http://wechat.scjinsui.com/weixin/wx/tglogin.jsp?phone=" + phone,
		    saveToAlbum: true,
		    saveImg: {
		        path: 'fs://'+ phone + '.png',
		        w: 250,
		        h: 250
		    }
		}, function(ret, err) {
			console.info("生成二维码结果：" + JSON.stringify(ret));
		    if (ret.status) {
		    alert("保存成功！");
//		    console.info("开始分享...");
//		    var sharedModule = api.require('shareAction');
//			sharedModule.share({
//				    text: '【金穗服务APP】我的推广二维码',
//				    type: 'image',
//				    path :ret.albumPath
//				});
//				console.info("分享结束...");
		    } else {
		        alert("保存失败...");
		    }
		});
	}
	
	
	
</script>
</html>